import axios from 'axios'
import { GetCookie } from '@/api/storage';
axios.interceptors.request.use(config => {
    let token = GetCookie("token");
    if (token) {
        // 设置请求头
        config.headers['Authorization'] = token
    }
    return config
}, function (error) {
    //如果请求出错在此执行某些操作
    return Promise.reject(error);
});

axios.interceptors.response.use(res => {
    //登录超时
    if (res.data.code == 400) {
        router.push('/')
    }
    return response;
}, function (error) {
    return Promise.reject(error);
});

